package com.qiaofang.housewarehouse.stub.feign.client.impl;

import com.qiaofang.common.exception.BusinessException;
import com.qiaofang.housewarehouse.stub.constants.ResponseCode;
import com.qiaofang.housewarehouse.stub.facade.RentalHouseQueryInfofacade;
import com.qiaofang.housewarehouse.stub.facade.SaleHouseQueryInfoFacade;
import com.qiaofang.housewarehouse.stub.feign.client.HouseQueryInfoClient;
import com.qiaofang.housewarehouse.stub.request.HouseQueryDetailRequest;
import com.qiaofang.housewarehouse.stub.request.RentHouseQueryPriceRequest;
import com.qiaofang.housewarehouse.stub.request.SaleHouseQueryPriceRequest;
import com.qiaofang.housewarehouse.stub.response.RentalHouseQueryDetailListResponse;
import com.qiaofang.housewarehouse.stub.response.RentalHouseQueryDetailResponse;
import com.qiaofang.housewarehouse.stub.response.SaleHouseQueryDetailListResponse;
import com.qiaofang.housewarehouse.stub.response.SaleHouseQueryDetailResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author: GJ
 * @Date: 2018/4/16 12:46
 * @Description:
 */
@Service
public class HouseQueyInfoClientImpl implements HouseQueryInfoClient {
    @Autowired
    private RentalHouseQueryInfofacade rentalHouseQueryInfofacade;
    @Autowired
    private SaleHouseQueryInfoFacade saleHouseQueryInfoFacade;

    @Override
    public SaleHouseQueryDetailListResponse getSaleHouseInfo(SaleHouseQueryPriceRequest saleHouseQueryRequest) {
        SaleHouseQueryDetailListResponse response = saleHouseQueryInfoFacade.getSaleHouseInfo(saleHouseQueryRequest);
        if (ResponseCode.RC_SUCCESS.getResponseCode().equals(response.getResponseCode())) {
            return response;
        } else {
            throw new BusinessException(response.getResponseCode(), response.getResponseMessage());
        }
    }

    @Override
    public RentalHouseQueryDetailListResponse getRentalHouseInfo(RentHouseQueryPriceRequest rentalHouseQueryRequest) {
        RentalHouseQueryDetailListResponse response = rentalHouseQueryInfofacade.getRentalHouseInfo(rentalHouseQueryRequest);
        if (ResponseCode.RC_SUCCESS.getResponseCode().equals(response.getResponseCode())) {
            return response;
        } else {
            throw new BusinessException(response.getResponseCode(), response.getResponseMessage());
        }
    }

    @Override
    public SaleHouseQueryDetailResponse getSaleHouseDetail(HouseQueryDetailRequest saleHouseQueryRequest) {
        return saleHouseQueryInfoFacade.getSaleHouseDetail(saleHouseQueryRequest);
    }

    @Override
    public RentalHouseQueryDetailResponse getRentalHouseDetail(HouseQueryDetailRequest rentalHouseQueryDetailRequest) {
        return rentalHouseQueryInfofacade.getRentalHouseDetail(rentalHouseQueryDetailRequest);
    }
}
